<% image_path_absolute = Setting.image_path_absolute %>
<% image_path_relative = Setting.image_path_relative %>


<table style="width: 100%;vertical-align: top;border:0;padding: 0;">
  <tr>
    <td style="width: 100px;vertical-align: top;border:0;">
      <% if material.image != "" && File.exists?("#{image_path_absolute}/#{material.image}") %>
        <%= image_tag "/#{image_path_relative}/#{material.image}", :alt => "#{t('no_image')}",  :width=>"70px"  %>
      <% else %>
        <%= image_tag "/#{image_path_relative}/empty_image.jpg", :alt => "#{t('no_image')}",  :width=>"70px"  %>
      <% end %>
    </td>
    <td>
      <table style="width: 100%;vertical-align: top;border:0;padding: 0;">
        <tr>
          <td  style="padding: 0;">
            <strong>
              <%
                 title = material.title
                 if !material.sub_title.nil? && material.sub_title != ""
                   title += " : #{material.sub_title}"
                 end
              %>
              <%=link_to title,
                :controller => "catalogs", :action => "show_material_details",
                :id => material.id %>
            </strong>
          </td>
        </tr>
        <tr>
          <td style="padding: 0;">
            <strong><%=t('lbl_catalog_author')%> </strong>
            <% first = true %>
            <%authors_sort = material.authors.sort_by {|a| a.full_name}%>
            <% authors_sort.each do |autor|%>
              <% if !first %>
               ;
              <% end %>
              <%=link_to "#{autor.full_name}",
                :controller => "catalogs", :action => "find_only_param",
                :id => 0,
                :author_id => autor.id%>
              <% first = false %>
            <% end %>
          </td>
        </tr>
        <tr>
          <td  style="padding: 0;">
            <% first = true %>
            <%publishers_sort = material.publishers.sort_by {|p| p.name}%>
            <% publishers_sort.each do |publisher|%>

              <% if !first %>
                <br/>
              <% end %>

              <%=link_to "#{publisher.city.name}", :controller => "catalogs", :action => "find_only_param", :id => 0, :country_id => publisher.city.state.country.id  %>
              <% if !publisher.city.nil? and publisher.city.name.size > 0  %>
              :
              <% end %>
              <%=link_to "#{publisher.name}",
                :controller => "catalogs", :action => "find_only_param",
                :id => 0, :publisher_id => publisher.id %>

              <% first = false %>
            <% end %>

            <% if !first &&  !material.edition_year.nil? && material.edition_year.size > 0  %>
            ,
            <% end %>
            <% if !material.edition_year.nil? && material.edition_year.size > 0%>
              <%= link_to "#{material.edition_year}.",
                :controller => "catalogs", :action => "find_only_param", :id => 0, :year => material.edition_year %>
            <% end %>
          </td>
        </tr>
        <% if !current_user.nil? %>
        <tr><td></td></tr>
          <tr>
            <td  style="padding: 0">
              <table style="padding: 0; border: 0; width: 300px" cellpadding="0" cellspacing="0">
                <tr style="padding: 0">
                  <td align="left"> <strong> <%="#{material.currency.symbol} #{"%.2f" % material.price}" %> </strong> </td>                  
                  <td align="right">
                    <strong>
                      <%= 
                      if  AdministratorSystem::AdministratorSystemProxy::material_stock(material) > 0 
                        t('material_stock_available')
                      else
                          t('material_stock_check_available')
                      end
                      %>
                    </strong></td>
                </tr>
              </table>

            </td>
          </tr>
        <% end %>
      </table>
    </td>
  </tr>
</table>